import type { CloudFilterBarScheme } from '@/components/filter-bar/types'
import { buildColumns } from '@/utils'

export default function useTableColumn() {
  const filterSchemes = computed<CloudFilterBarScheme>(() => {
    return {
      widgets: [
        {
          widget: 'input',
          field: 'name_keyword',
          icon: true,
          placeholder: '请输入规则名称'
        }
      ]
    }
  })
  const columns = computed(() =>
    buildColumns([
      {
        width: 48,
        dataIndex: 'sort',
        slotName: 'sort'
      },
      {
        title: '优先级',
        width: 74,
        dataIndex: 'priority'
      },

      {
        title: '规则名称',
        width: 321,
        dataIndex: 'name'
        // format: 'copy'
      },
      {
        title: '说明',
        width: 321,
        dataIndex: 'condition_description',
        slotName: 'condition_description'
      },
      {
        title: '状态',
        width: 88,
        dataIndex: 'status',
        slotName: 'status'
      },
      {
        title: '创建时间',
        width: 180,
        dataIndex: 'created_at',
        slotName: 'created_at',
        format: 'date-time',
        sortable: sortableSettings
      },
      {
        title: '操作',
        width: 120,
        slotName: 'action',
        cellClass: 'actions-cell',
        fixed: 'right'
      }
    ])
  )
  return {
    columns,
    filterSchemes
  }
}
